<template>
  <component
    :is="componentName"
    v-bind="$attrs"
    v-on="$listeners"
    @after-save="afterSave"
  >
    <slot></slot>
  </component>
</template>

<script>
import { firstUpperCase } from '@/utils'
export default {
  name: 'DetailContainer',
  components: {
    ProductDetail: () =>
      import('@/views/product/productConfig/components/Detail/index.vue'), // 产品上架 processType === 1
    CustomerDetail: () =>
      import('@/views/customer/customerList/components/detail/index'), // 客户详情
    SaleDetail: () => import('@/views/saleOrder/saleOrderList/Detail/index'), // 销售单详情
    ReceivableDetail: () =>
      import('@/views/financial/receivableList/components/detail/index'), // 回款录入审批
    ReturnDetail: () =>
      import('@/views/saleOrder/saleOrderList/Detail/ReturnDetail/index'), // 退款详情
    SpecialPriceDetail: () =>
    import('@/views/product/productSpecialPrice/components/Detail/index'), // 特殊价格配置详情
    ActivationDetail: () =>
    import('@/views/financial/productActivation/components/detail/msgJump'), // 产品激活
    CustomerFollowDetail: () =>
    import('@/views/customer/customerFollow/components/msgJump')// 客户跟进

  },
  props: {
    type: {
      type: String,
      default: '1'
    },
    // 是否为审批模板
    isApproveTemplate: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      // 审批类型的详情模板
      approveTemplate: {
        '1': 'Product',
        '2': 'SpecialPrice',
        '3': 'Sale',
        '4': 'Sale',
        '5': 'Sale',
        '6': 'Return',
        '7': 'Receivable',
        '8': 'SpecialPrice',
        '9': 'Sale', // 包场销售单
        '10': 'Sale', // 客诉销售单
        '12': 'Sale', // 实物销售单
        '13': 'Sale' // 文旅销售单
      },
      // 非审批类型的详情模板
      detailTemplate: {
        '5': 'Activation', // 产品激活
        '6': 'Sale', // 全部回款-> 销售单列表详情
        '7': 'Sale', // 逾期提醒 -> 销售单列表-详情
        '8': 'Customer', // 移入公海 -> 客户列表-详情
        '9': 'Customer', // 转移客户
        '10': 'Customer', // 客户分配
        '11': 'CustomerFollow' // 客户跟进
      }
    }
  },
  computed: {
    componentName () {
      console.log(this.type, this.isApproveTemplate, 'tye')
      if (this.isApproveTemplate) {
        return `${this.approveTemplate[this.type]}Detail`
      } else {
        return `${this.detailTemplate[this.type]}Detail`
      }
    }
  },
  watch: {},
  created () {
  },
  methods: {
    afterSave () {
      this.$emit('after-save')
    }
  }
}
</script>
